import { request } from "@/utils/service"
import type * as Department from "./types/department"

export function addDepartmentDataApi(data: Department.IAddDepartmentRequestData) {
  return request({
    url: "department/addOne",
    method: "post",
    data
  })
}

/** 删 */
export function deleteDepartmentDataApi(id: number) {
  return request({
    url: `department/deleteOne`,
    method: "delete",
    params: { id: id.toString() }
  })
}

/** 改 */
export function updateDepartmentDataApi(data: Department.IUpdateDepartmentRequestData) {
  return request({
    url: "department/updateOne",
    method: "put",
    data
  })
}

/** 查 */
export function getDepartmentDataApi(params: Department.IGetDepartmentRequestData) {
  return request<Department.GetDepartmentResponseData>({
    url: "department/getList",
    method: "get",
    params
  })
}
export function getDepartmentIdAndNameList(data: { name: string; departmentId: number | undefined }) {
  return request<Department.GetDepartmentIdAndNameResponseData>({
    url: "department/getIdAndNameList",
    method: "get",
    params: data
  })
}
